<%@ page contentType="text/html;charset=UTF-8"%>
<%@ page
	import="org.apache.shiro.web.filter.authc.FormAuthenticationFilter"%>
<%@ page import="org.apache.shiro.authc.ExcessiveAttemptsException"%>
<%@ page import="org.apache.shiro.authc.IncorrectCredentialsException"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<c:set var="ctx" value="${pageContext.request.contextPath}" />

<html>
<head>
<title>登录页</title>
</head>

<body>
	<form id="loginForm" action="${ctx}/login" method="post"
		class="form-horizontal">
		<%
	String error = (String) request.getAttribute("message");
	if(error != null){
	%>
		<div class="alert alert-error input-medium controls">
			<button class="close" data-dismiss="alert">×</button><%=error %>
		</div>
		<%
	}
	%>
		<div class="control-group">
			<label for="username" class="control-label">名称:</label>
			<div class="controls">
				<input type="text" id="username" name="loginName"
					value="${username}" class="input-medium required" />
			</div>
		</div>
		<div class="control-group">
			<label for="password" class="control-label">密码:</label>
			<div class="controls">
				<input type="password" id="password" name="password"
					class="input-medium required" />
			</div>
		</div>

		<div class="control-group">
			<label for="password" class="control-label">验证码:</label>
			<div class="controls">
				<img id="captchaImg" alt="点击刷新验证码" onclick="reloadValidateCode();"
					src="${ctx}/login/getCaptcha" width="50px" height="20px"
					style="border: 1px solid #898989; width: 55px; height: 25px; vertical-align: middle; cursor: pointer;" />
				<input type="text" id="captcha" name="captcha"
					class="input-medium required" style="width: 50px" />
			</div>

		</div>
		<div class="control-group">
			<div class="controls">
				<label class="checkbox" for="rememberMe"><input
					type="checkbox" id="rememberMe" name="rememberMe" /> 记住我</label> <input
					id="submit_btn" class="btn btn-primary" type="submit" value="登录" />
				<a class="btn" href="${ctx}/register">注册</a> <span
					class="help-block">(管理员: <b>admin/admin</b>, 普通用户: <b>user/user</b>)
				</span>
			</div>
		</div>
	</form>

	<script>
// 		$(document).ready(function() {
// 			$("#loginForm").validate();
// 		});		
		
	    function reloadValidateCode() {
	        document.getElementById("captchaImg").src="${ctx}/login/getCaptcha?date =" + new Date().getTime();
	    }

	</script>
</body>
</html>
